<!--
@author	Yi Bo <etng2004@gmail.com>
@version	$Id: __list_template.php 24 2007-08-29 09:14:57Z etng2004 $
@copyrithg	2006-2007 ETE.CN
@license 	PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}
-->
<?php
$this->declareVars();
require_once(dirname(__FILE__) . '/_meta_contact.php');
echo $this->render('header.php');
//$this->dump($this->contacts);

/**
 * 列表相应参数
 */
$checkbox_group = 'Contact';
?>
<script type="text/javascript">
<!--
function validateBatchOperateForm(checkboxGroup)
{
	var errors=[];
	if(!checkboxGroup.selected.length)errors.push('请选择至少一个对象！');

//	var f_status = document.getElementById('field_status');
//	var v_status = f_status.options[f_status.selectedIndex].value;
//	if(v_status=="")errors.push('请选择至少一种批量操作！');

	if(errors.length)
	{
		alert("请纠正以下错误后再继续操作：\n\n"+errors.join("\n"));
		return false;
	}
	return true;
}
//-->
</script>

<table cellspacing="0" cellpadding="0" border="0">
  <tr>
    <td><!--表头区域，可以用来做搜索等信息的展示-->
    </td>
  </tr>
  <tr>
    <td align="center" valign="top"><form method="post" action="<?php echo $this->base_url; ?>/batchOperate/" id="frmBatchOperate" name="frmBatchOperate" onSubmit="return validateBatchOperateForm(<?php echo $checkbox_group;?>ChkGroup);">
        <table cellspacing="0" cellpadding="0" id="<?php echo strtolower($checkbox_group);?>_list">
          <tr>
            <td> - </td>
            <td> 操作 </td>
          </tr>
          <?php
        if(!$this->contacts):
	?>
          <tr>
            <td colspan="20"> 无记录 </td>
          </tr>
          <?php
        else:
        foreach ($this->contacts as $contact):
	?>
          <tr>
            <td><input type="checkbox" name="fields[<?php echo strtolower($checkbox_group);?>_id][]" id="fields_<?php echo strtolower($checkbox_group);?>_<?php echo $contact['id']; ?>" value="<?php echo $contact['id']; ?>"/>
            </td>
            <td><?php echo $contact['id'] ?></td>
            <td><?php echo date('Y-m-d', $contact['created_at']); ?></td>
            <td><a href=" <?php echo $this->base_url;?>/view/id/<?php echo $contact['id'] ?>">查看</a> <a href=" <?php echo $this->base_url;?>/edit/id/<?php echo $contact['id'] ?>">编辑</a> <a href=" <?php echo $this->base_url;?>/remove/id/<?php echo $contact['id'] ?>">删除</a> <a href=" <?php echo $this->base_url;?>/contact/id/<?php echo $contact['id'] ?>">联系人</a> </td>
          </tr>
          <?php
        endforeach;
	?>
          <tr>
            <td colspan="20"><a href="javascript:void(0);" onClick="<?php echo $checkbox_group;?>ChkGroup.all();">全选</a> <a href="javascript:void(0);" onClick="<?php echo $checkbox_group;?>ChkGroup.inverse();">反选</a> <a href="javascript:void(0);" onClick="<?php echo $checkbox_group;?>ChkGroup.clear();">不选</a> 对选中的对象：
              <select name="operate[status]" id="field_status">
                <option value="">===审核===</option>
                <?php
$lang_status_op = array();
foreach ($lang_status_op as $status => $text) {
	if($this->status==$status)continue;
	echo "<option value=\"{$status}\">{$text}</option>\n";
}
  ?>
              </select>
              <input type="submit" value="设置"  />
            </td>
          </tr>
          <tr>
            <td colspan="20"><?php
          echo $this->pagination($this->pager['total'], $this->pager['curpage'], $this->pager['perpage'], $this->pager['url'] );
?>
            </td>
          </tr>
          <?php
        endif;
	?>
        </table>
      </form>
      <script type="text/javascript">
      <!--
      var <?php echo $checkbox_group;?>ChkGroup = new EtCheckboxes('<?php echo strtolower($checkbox_group);?>_list','fields_<?php echo strtolower($checkbox_group);?>_',[]);
      //-->
</script>
    </td>
  </tr>
  <tr>
    <td>others</td>
  </tr>
</table>
<br />
<div class="develop_notice1">
    <h3>Head</h3>
    <textarea name="CRMLiteDevelopCodeListHead" rows="10" cols="50" wrap="off" onfocus="this.select();">
    <?php
        foreach ($contact as $field => $value):
	?>
	<td>&lt;?php echo $meta['fields']['<?php echo $field; ?>'];?&gt;</td>
	 <?php
        endforeach;
	?>
</textarea>
    <h3>Body</h3>
    <textarea name="CRMLiteDevelopCodeListBody" rows="10" cols="50" wrap="off" onfocus="this.select();">
     <?php
        foreach ($contact as $field => $value):
	?>
	<td>&lt;?php echo $contact['<?php echo $field; ?>'];?&gt;</td>
	 <?php
        endforeach;
	?>
</textarea>
</div>
<?php echo $this->render('footer.php');?>